package com.ywgt.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StreamTest {
    public static void main(String[] args) {
        /**
         * 1.no为偶数
         * 2.年龄大于21岁
         * 3.用户名转为大写
         * 4.用户名字母倒叙
         * 5.至打印一个用户
         */
        User user1=new User(1,"a",23);
        User user2=new User(2,"b",25);
        User user3=new User(3,"c",21);
        User user4=new User(4,"d",18);
        User user5=new User(6,"e",26);
        List<User> list = Arrays.asList(user1, user2, user3, user4, user5);
        list.stream().filter((u)->{return u.getNo()%2==0;})
                .filter((u)->{return u.getAge()>21;})
                .map((u)->{return u.getId().toUpperCase();})
                .sorted((u1,u2)->{return u2.compareTo(u1);})
                .limit(1)
                .forEach(System.out::println);


    }
}
